﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AfterlifeLib.GameScreens;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Media;
using AfterlifeLib.GameScreens.Menus;

namespace Afterlife.Screens
{
    public class PauseMenuScreen : MenuScreen
    {
        public PauseMenuScreen()
            : base("Paused")
        {
            IsPopup = true;

            MenuEntry resumeMenuEntry = new MenuEntry("Resume");
            MenuEntry optionsMenuEntry = new MenuEntry("Options");
            MenuEntry quitMenuEntry = new MenuEntry("Quit");

            resumeMenuEntry.Selected += OnCancel;
            optionsMenuEntry.Selected += OptionsMenuEntrySelected;
            quitMenuEntry.Selected += QuitMenuEntrySelected;

            MenuEntries.Add(resumeMenuEntry);
            MenuEntries.Add(optionsMenuEntry);
            MenuEntries.Add(quitMenuEntry);
        }

        void OptionsMenuEntrySelected(object sender, EventArgs e)
        {
            ScreenManager.AddScreen(new MainOptionsScreen(true));
        }

        void QuitMenuEntrySelected(object sender, EventArgs e)
        {
            LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen("Images/UI/background"), new MainMenuScreen());
            MediaPlayer.Stop();
        }

        public override void Draw(GameTime gameTime)
        {
            ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3);

            base.Draw(gameTime);
        }
    }
}
